using System.Text;
using Core;

namespace Services
{
	internal class IniFileService : IIniFileService
	{
		public string ReadStringValue(string filePath, string section, string key)
		{
			StringBuilder stringBuilder = new StringBuilder(255);
			NativeMethods.GetPrivateProfileString(section, key, string.Empty, stringBuilder, stringBuilder.Capacity, filePath);
			return stringBuilder.ToString();
		}

		public int ReadIntValue(string filePath, string section, string key)
		{
			return (int)NativeMethods.GetPrivateProfileInt(section, key, 0, filePath);
		}

		public bool WriteStringValue(string filePath, string section, string key, string value)
		{
			return NativeMethods.WritePrivateProfileString(section, key, value, filePath);
		}
	}
}
